<?php

// 启动 session
session_start();

// 检查登录状态
if (isset($_SESSION['username']) && isset($_SESSION['isadmin'])) {
    // 用户已登录，返回用户数据
    $username = $_SESSION['username'];
    $isadmin = $_SESSION['isadmin'];
    $userid = $_SESSION['userid'];

    echo json_encode([
        'Code' => 200,
        'Msg' => '已登录',
        'Data' => [
            'username' => $username,
            'isadmin' => $isadmin,
            'userid' => $userid
        ]
    ], JSON_UNESCAPED_UNICODE);
    exit();
} else {
    // 用户未登录
    echo json_encode(['Code' => 401, 'Msg' => '未登录或登录失效', 'Ret' => "False"], JSON_UNESCAPED_UNICODE);
    exit();
}
?>